package com.jzr.board.auth;

import org.springframework.security.crypto.password.PasswordEncoder;

public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        if(rawPassword == null){
            return "";
        }
        System.out.println("rawPassword->encode:" + rawPassword);
        return rawPassword.toString();
        //return MD5Util.MD5((String)rawPassword);
    }

    @Override
    public boolean matches(CharSequence inputPassword, String systemPassword) {
        if(inputPassword == null || systemPassword == null){
            return false;
        }
        //System.out.println("matches -> inputPassword:"+inputPassword+",systemPassword:"+systemPassword);
        return inputPassword.toString().equals(systemPassword);
        //System.out.println("matches result:"+MD5Util.MD5(systemPassword).equals(inputPassword));
        //return MD5Util.MD5(systemPassword).equals(inputPassword);
    }
}
